package com.example.demo.reflectstudy;

import com.example.demo.setstudy.Student;

import java.lang.reflect.Constructor;

/**
 * @Description Reflect01
 * @Author songchuanlong
 * @Date 2025-06-08
 */

/**
 * 获取class对象
 */
public class Reflect01 {
    public static void main(String[] args) {
        Class c1 = Student.class;
        System.out.println(c1.getName());//获取全类名
        System.out.println(c1.getSimpleName());//获取类名


        Student student = new Student();
        Class c2 = student.getClass();
        System.out.println(c2.getName());


        //获取构造器
        Constructor[] declaredConstructors = c1.getDeclaredConstructors();
        for (Constructor declaredConstructor : declaredConstructors) {
            System.out.println(declaredConstructor.getName()+"---->"+declaredConstructor.getParameterCount());
        }
    }
}
